﻿using System;
using System.Diagnostics;
using ebcmassendaten.messages;
using ebcmassendaten.specifications;
namespace ebcmassendaten.recordbuilder
{
    public class RecordBuilder : IRecordBuilder
    {
        private bool HeaderRaised = false;

        public void In_Line(string msg)
        {
            var Record = new Record {Fields = msg.Split(',')};
            Trace.TraceInformation("Record created");

            if (HeaderRaised == false)
            {
                Trace.TraceInformation("raise Header");
                Out_Header(Record);

                HeaderRaised = true;
            }
            else
            {
                Trace.TraceInformation("raise Line");
                Out_Record(Record);
            }

        }

        public event Action<Record> Out_Header;
        public event Action<Record> Out_Record;
    }
}